const checkCardNo = (rule, value, callback) => {
  // 身份证号
  const regIdCard = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
  if (!value) {
    return callback(new Error('必须填写证件号码'))
  } else if (rule.card_type === '1' && !regIdCard.test(value)) {
    return callback(new Error('身份证号格式错误'))
  } else {
    return callback()
  }
}
// const checkMobile = (rule, value, callback) => {
//   console.log(value)
//   const regIdCard = /^1[3456789]\d{9}$/
//   if (!value) {
//     return callback(new Error('必须填写'))
//   } else if (value.length === 11 && !regIdCard.test(value)) {
//     return callback(new Error('手机号格式错误'))
//   } else {
//     return callback()
//   }
// }

export default {
  ruleValidate: {
    name: [{ required: true, message: '必须填写', trigger: 'blur' }],
    card_no: [{ required: true, validator: checkCardNo, trigger: 'blur' }],
    mobile: [{ required: true, message: '必须填写', trigger: 'blur' }],
    address: [{ required: true, message: '必须填写', trigger: 'blur' }],
    unit: [{ required: true, message: '必须填写', trigger: 'blur' }],
    resident: [{ required: true, message: '必须填写', trigger: 'change' }],
    job: [{ required: true, message: '必须填写', trigger: 'change' }],
    state: [{ required: true, message: '必须填写', trigger: 'change' }],
    point: [{ required: true, message: '必须填写', trigger: 'change' }],
    level: [{ required: true, message: '必须填写', trigger: 'change' }],
    point_state: [{ required: true, message: '必须填写', trigger: 'change' }]
  }
}
